package com.ego.product.vo;

import com.ego.product.po.Category;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * @program: ego
 * @description: 二级分类VO
 * @author: KamTang
 * @create: 2022-11-30 12:13
 **/
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class SecondLevelCategoryVo {
    /**
     * 父分类ID
     */
    private Long parentId;
    private Long id;
    private String name;
    /**
     * 三级分类
     */
    private List<ThirdLevelCategoryVo> thirdLevelCategoryVo;

    public SecondLevelCategoryVo init(Category parent, Category source, List<ThirdLevelCategoryVo> thirdLevelCategories) {
            SecondLevelCategoryVo vo = new SecondLevelCategoryVo();
            vo.setParentId(parent.getCatId());
            vo.setId(source.getCatId());
            vo.setName(source.getName());
            vo.setThirdLevelCategoryVo(thirdLevelCategories);
            return vo;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class ThirdLevelCategoryVo {
        private Long parentId;
        private Long id;
        private String name;

        public ThirdLevelCategoryVo init(Category parent, Category source) {
            ThirdLevelCategoryVo vo = new ThirdLevelCategoryVo();
            vo.setParentId(parent.getCatId());
            vo.setId(source.getCatId());
            vo.setName(source.getName());
            return vo;
        }
    }
}
